package com.devframe.web.struts1.converters;

import java.text.ParseException;
import java.util.Date;

/**
 * 
 *<pre><b><font color="blue">TimestampConverter</font></b></pre>
 *
 *<pre><b>&nbsp;--描述说明--</b></pre>
 * <pre></pre>
 * <pre>
 * <b>--样例--</b>
 *   TimestampConverter obj = new TimestampConverter();
 *   obj.method();
 * </pre>
 * JDK版本：JDK1.4
 * @author  <b></b>
 */
public class TimestampConverter extends DateConverter {
	/**
	 * @param class0 Class
	 * @param object Object
	 * @return Object
	 */
	public Object convert(Class class0, Object object) {
		Date date = (Date) super.convert(Date.class, object);
		if (date == null) {
			return null;
		} else {
			return new java.sql.Timestamp(date.getTime());
		}
	}
	/**
	 * 测试
	 * @param args String[]
	 * @throws ParseException ParseException
	 * @author:Administrator
	 */
	public static void main(String[] args) throws ParseException {
		TimestampConverter tc = new TimestampConverter();
		Object obj = tc.convert(java.sql.Timestamp.class, "2005-12-11 13:17");
		DateConverter dc = new DateConverter();
		obj = dc.convert(Date.class, "2005-12-11");
		System.out.print(obj);
	}
}
